package com.windoent.yugioh.adapter.brvah;

import android.widget.TextView;

import androidx.annotation.NonNull;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;
import com.windoent.yugioh.R;
import com.windoent.yugioh.bean.CaiPanListData;
import com.windoent.yugioh.utils.BaseMethod;
import com.windoent.yugioh.utils.SimpleUtils;
import com.windoent.yugioh.widget.RoundImageView;

/**
 * author : robert
 * date   : 2021/5/6 15:26
 * desc   :主裁判
 */
public class BaoMingAuthCaiPanMainAdapter extends BaseQuickAdapter<CaiPanListData.DataBean.RefereeBean, BaseViewHolder> {

    public BaoMingAuthCaiPanMainAdapter() {
        super(R.layout.item_baoming_auth_caipan_main, null);
    }

    @Override
    protected void convert(@NonNull BaseViewHolder helper, CaiPanListData.DataBean.RefereeBean item) {
        helper.setText(R.id.tv_name, BaseMethod.notNullDefaultValueNull(item.getNickname()))
                .setText(R.id.tv_id, getContext().getString(R.string.string_user_info_id) + BaseMethod.notNullDefaultValueNull(item.getRefereeViewId() + ""));
        RoundImageView view = helper.getView(R.id.image);
        SimpleUtils.loadImageForView(getContext(), view, item.getAvatar(), R.drawable.img_official_avatar_android);
        TextView textView = helper.getView(R.id.tv_button);
        int status = item.getStatusId();//1审核中，2通过
        setText(textView, status);
    }

    private void setText(TextView textView, int status) {
        if (status == 1) {
            //去通过
            textView.setSelected(false);
            textView.setText(getContext().getString(R.string.string_baoming_auth_caipan_pass_games));
        } else if (status == 2) {
            //去退赛
            textView.setSelected(true);
            textView.setText(getContext().getString(R.string.string_baoming_auth_caipan_exit_games));
        }
    }
}